package com.example.jpa.dao;

import com.example.jpa.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserRepository extends JpaRepository<User,Long> {

    /**
     * 根据用户名去查询用户信息
     * @return
     */
    public User findUserByUsername(@Param("username") String username);

    /**
     * 自定义SQL查询
     * @return
     */
    @Query(value="select * from user where address like %:address%",nativeQuery=true)
    List<User> findUserByAddressSQL(@Param("address") String address);


}
